package com.moyq5.mvc.framework.jackson.result;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 
 * 
 * @author mo_yq5@163.com
 * @date 2013-6-15
 * 
 */
public class StatusResult {
	
	public enum Status {
		OK, FAIL, ERROR;
	}

	/**
	 * 状态
	 */
	@JsonSerialize
	private Status status = Status.FAIL;
	/**
	 * 状态信息描述
	 */
	@JsonSerialize
	private String message = "";
	/**
	 * 错误码
	 */
	@JsonSerialize
	private String code = "";
	
	public StatusResult() {
		
	}
	
	public StatusResult(Status status) {
		this.status = status;
		this.message = status.name();
	}
	
	public StatusResult(Status status, String message) {
		this.status = status;
		this.message = message;
	}
	
	public void setStatus(Status status) {
		this.status = status;
	}

	public void setOk() {
		this.status = Status.OK;
		this.message = Status.OK.name();
	}

	public void setFail() {
		this.status = Status.FAIL;
	}

	public void setError() {
		this.status = Status.ERROR;
	}
	
	public void setCode(String code) {
		this.code = code;
	}

	public void setMessage(String msg) {
		this.message = msg;
	}

	public void setOkMessage(String message) {
		this.status = Status.OK;
		this.message = message;
	}

	public void setFailMessage(String message) {
		this.status = Status.FAIL;
		this.message = message;
	}

	public void setFailMessage(String code, String message) {
		this.status = Status.FAIL;
		this.code = code;
		this.message = message;
	}

	public void setErrorMessage(String message) {
		this.status = Status.ERROR;
		this.message = message;
	}

	public void setErrorMessage(String code, String message) {
		this.status = Status.ERROR;
		this.code = code;
		this.message = message;
	}

	public Status getStatus() {
		return status;
	}

	public String getMessage() {
		return message;
	}
	
	public String getCode() {
		return code;
	}

}
